import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'
import ViteAutoImport from "unplugin-auto-import/vite";
import {visualizer} from 'rollup-plugin-visualizer'
import Components from 'unplugin-vue-components/vite';
import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers';
import AutoImport from 'unplugin-auto-import/vite'
import {ElementPlusResolver} from 'unplugin-vue-components/resolvers'
import { NaiveUiResolver } from 'unplugin-vue-components/resolvers'
import ckeditor5 from '@ckeditor/vite-plugin-ckeditor5'
import { createRequire } from 'node:module';
import { webUpdateNotice } from '@plugin-web-update-notification/vite';
const require = createRequire( import.meta.url );
function resolve(url){
  return path.resolve(__dirname,url)
}

// https://vitejs.dev/config/
export default defineConfig({
  //配置@别名
  resolve:{
    alias:{
      "@":resolve("./src"),
      "@netWork":resolve("./src/network"),
      "@utils":resolve("./src/utils"),
    }
  },
  plugins: [
      ViteAutoImport({
        imports: ['vue', 'vue-router', 'pinia'],
      }),
      visualizer(),
      vue(),
    { theme: ckeditor5( '@ckeditor/ckeditor5-theme-lark' ) },
    AutoImport({
      resolvers: [ElementPlusResolver(),AntDesignVueResolver(),NaiveUiResolver()],
    }),
    Components({
      resolvers: [
        AntDesignVueResolver({
          importStyle: false, // css in js
          resolveIcons: true, // resolve icon components
        }),
        ElementPlusResolver(),
        NaiveUiResolver()
      ],
    },),
    webUpdateNotice({
      logVersion: true,
      notificationConfig:{
        placement: 'topRight',
      },
      checkInterval: 1000 * 60,
      notificationProps: {
        title: '系统更新',
        description: '系统已更新，请刷新页面',
        buttonText: '刷新',
        dismissButtonText: '忽略',
      },
    }),
  ],
  css: {
    loaderOptions: {
      less: {
        lessOptions: {
          // 在这里添加自定义的Less配置
        },
      },
    },
  },
  build:{
    chunkSizeWarningLimit:1500,
  },
  server:{
    port:5553
  }
})
